<template>
	<view class="Recharge_content Transfer_content">
		<view class="kuang">
			<view class="title">
				<view class="inline-block left">
					<image src="../../static/image/left.png" mode="" @tap="back"></image>
				</view>
				<view class="inline-block titleText">
					{{i18n.cxzctitleText}}
				</view>
			</view>
		
			<view class="choice" style="margin-top: 50upx;">
				<text>{{i18n.zcname1}}</text>
				<input type="text" value="" v-model="assetKey" :placeholder="i18n.zcname2" class="vote_num" placeholder-style="font-size:12px;color:#C2C9DF"/>
			</view>
			<text class="vote_encourage" style="margin-top: 15upx;" @tap="issue">{{i18n.bottombutton}}</text>
			
			<view class="query_result">
				<view class="result_item">
					<text>{{i18n.zcname3}}</text>
					<text>{{assetId}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname4}}</text>
					<text>{{assetName}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname5}}</text>
					<text>{{symbol}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname6}}</text>
					<text>{{number}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname7}}</text>
					<text>{{stats}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname8}}</text>
					<text>{{amount}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname9}}</text>
					<text>{{decimals}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname10}}</text>
					<text>{{founder}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname11}}</text>
					<text>{{owner}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname12}}</text>
					<text>{{addIssue}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname13}}</text>
					<text>{{upperLimit}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname14}}</text>
					<text>{{contract}}</text>
				</view>
				<view class="result_item">
					<text>{{i18n.zcname15}}</text>
					<text>{{description}}</text>
				</view>
			</view>
			
			<view class="bottombutton" @tap="searchAsset">
				{{i18n.zcname16}}
			</view>
			
		</view>


	</view>
</template>

<script>
	import * as oexWeb3 from 'oex-web3';
	import BigNumber from 'bignumber.js';
	
	export default {
		computed: {
			i18n() {
				return this.$t('user')
			}
		},
		data() {
			return {
				assetKey: "",
				assetId: 0,
				assetName: "",
				number: 0,
				stats: 0,
				symbol: "",
				amount: 0,
				decimals: 0,
				founder: "",
				owner: "",
				addIssue: 0,
				upperLimit: 0,
				contract: "",
				description: "",
			}
		},
		onLoad() {

		},
		methods: {
			
			back() {
				this.$CommonJS.navigateBack()
			},
			issue() {
				// this.$CommonJS.navigateTo('./issue')
				uni.navigateBack({
					url:"./issue"
				})
			},
			searchAsset() {
				this.assetKey = this.assetKey.trim();
				var assetPromise = null;
				if (isNaN(this.assetKey)) {
					assetPromise = this.$Web3Wrapper.getAssetInfoByName(this.assetKey);
				} else {
					assetPromise = this.$Web3Wrapper.getAssetInfoById(parseInt(this.assetKey));
				}
				assetPromise.then(assetInfo => {
					this.assetId = assetInfo.assetId;
					this.assetName = assetInfo.assetName;
					this.number = assetInfo.number;
					this.stats = assetInfo.stats;
					this.symbol = assetInfo.symbol;
					this.amount = new BigNumber(assetInfo.amount).shiftedBy(this.decimals * -1).toNumber();
					this.decimals = assetInfo.decimals;
					this.founder = assetInfo.founder;
					this.owner = assetInfo.owner;
					this.addIssue = new BigNumber(assetInfo.addIssue).shiftedBy(this.decimals * -1).toNumber();
					this.upperLimit = new BigNumber(assetInfo.upperLimit).shiftedBy(this.decimals * -1).toNumber();
					
					this.contract = assetInfo.contract == null ? '无' : assetInfo.contract;
					this.description = assetInfo.description;
				})
			}
		}
	}
</script>

<style lang="stylus">
	@import "../../static/stylus/assets/assets.stylus"
</style>
